<template>
  <div class="editor-wrapper" >
    <transition name="fadeRight">
      <div  class="editor-content" >
        <div class="top">
          <i class="icon-ic_editor"></i>
        </div>
        <el-form label-position="left" labelWidth="100px">

          <el-form-item label="文件名称">
            <input style="width: calc(100% - 40px)" v-model="fileName" class="borderLine-input" type="text">
          </el-form-item>
          <el-form-item label="文件内容">
            <p class="textareacount">{{this.fileContent.length}}</p>
            <el-input
              class="editor-updatatextarea"
              type="textarea"
              placeholder="请输入内容"
              v-model="fileContent">
            </el-input>
          </el-form-item>
        </el-form>
        <el-button round class="elbutton-style sureBtn" @click="sure">提交</el-button>
      </div>
    </transition>
  </div>
</template>

<script type="text/ecmascript-6">
  import * as noteApi from '../../api/moudle/noteApi'

  export default {
    props: {
    },
    data() {
      return {
        fileContent: '',
        fileName: ''
      }
    },
    created() {
    },
    methods: {
      sure() {
        let body = {
          'fileContent': this.fileContent,
          'fileName': this.fileName
        }
        noteApi.updateNote(this.fileName, body).then((res) => {
          console.log(res)
          this.$message.success('提交成功')
          this.$router.push('/view')
          this.$emit('updateSuccess')
        }, reject => {
          this.$message.error('提交失败')
        })
      }
    }
  }
</script>

<style lang="scss">
  @import "../../common/scss/base";

  .editor-wrapper {
    top: 72px;
    width: 100%;
    height:100%;
    background-color: rgba(255, 255, 255, 0.5);
    z-index: 100;
  }
  .editor-content {
    width: 100%;
    height: 100%;
    margin-right: 0;
    background-color: white;
    box-shadow: 0 2px 6px rgba(120, 120, 120, 0.5);
    overflow: scroll;
    overflow-x: hidden;
    overflow-y: hidden;
  }
  .editor-content .top {
    padding-left: 41px;
    padding-top: 22px;
    position: relative;
  }
  .editor-content .top span {
    color: $mainTitleColor;
    font-size: 14px;
    line-height: 24px;
  }
  .editor-content .top p {
    position: absolute;
    top: 22px;
    right: 24px;
    font-size: 12px;
    color: #354052;
    line-height: 24px;
  }
  .editor-content .top .el-switch {
    position: absolute;
    right: 104px;
    top: 24px;
  }
  .editor-content .el-form {
    margin-top: 24px;
    margin-left: 60px;
  }
  .editor-content .el-form .el-form-item {
    margin-bottom: 5px;
  }
  .editor-content .el-form .el-form-item label {
    font-size: 14px;
    color: $subTitleColor;
  }
  .editor-content .el-form .el-form-item .versioninput {
    width: calc(100% - 40px);
    font-size: 14px;
    color: $mainTitleColor;
  }

  .editor-content .el-form .el-form-item .textareacount {
    text-align: right;
    padding-right: 40px;
  }

  .editor-content .editor-updatatextarea {
    width: calc(100% - 40px);
    font-size: 14px;
    color: $mainTitleColor;
  }
  .editor-content .editor-updatatextarea textarea {
    height: 222px !important;
    outline: 0;
    padding-left: 5px;
  }
  .editor-content .el-button {
    margin-top: 48px;
  }
  .editor-content .el-button span {
    line-height: 36px !important;
  }
  .editor-content .sureBtn {
    background-color: $mainColor !important;
    color: white !important;
    margin-left: calc(100% - 40px - 96px - 96px - 10px);
  }
</style>
